/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.interpreter.frontends.functional;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Laurent WOUTERS
 */
public class AxiomLoader {
    public static xowl.lang.owl2.Axiom load(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        String name = node.getName();
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDeclaration)) return load_Declaration(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDisjointClasses)) return load_DisjointClasses(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDisjointUnion)) return load_DisjointUnion(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomEquivalentClasses)) return load_EquivalentClasses(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSubClassOf)) return load_SubClassOf(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDataPropertyDomain)) return load_DataPropertyDomain(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDataPropertyRange)) return load_DataPropertyRange(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDisjointDataProperties)) return load_DisjointDataProperties(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomEquivalentDataProperties)) return load_EquivalentDataProperties(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomFunctionalDataProperty)) return load_FunctionalDataProperty(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSubDataPropertyOf)) return load_SubDataPropertyOf(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDatatypeDefinition)) return load_DatatypeDefinition(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomClassAssertion)) return load_ClassAssertion(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDataPropertyAssertion)) return load_DataPropertyAssertion(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDifferentIndividuals)) return load_DifferentIndividuals(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomNegativeDataPropertyAssertion)) return load_NegativeDataPropertyAssertion(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomNegativeObjectPropertyAssertion)) return load_NegativeObjectPropertyAssertion(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomObjectPropertyAssertion)) return load_ObjectPropertyAssertion(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSameIndividual)) return load_SameIndividual(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomAsymmetricObjectProperty)) return load_AsymmetricObjectProperty(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDisjointObjectProperties)) return load_DisjointObjectProperties(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomEquivalentObjectProperties)) return load_EquivalentObjectProperties(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomFunctionalObjectProperty)) return load_FunctionalObjectProperty(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomInverseFunctionalObjectProperty)) return load_InverseFunctionalObjectProperty(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomInverseObjectProperties)) return load_InverseObjectProperties(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomIrreflexiveObjectProperty)) return load_IrreflexiveObjectProperty(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomObjectPropertyDomain)) return load_ObjectPropertyDomain(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomObjectPropertyRange)) return load_ObjectPropertyRange(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomReflexiveObjectProperty)) return load_ReflexiveObjectProperty(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSubObjectPropertyOf)) return load_SubObjectPropertyOf(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSymmetricObjectProperty)) return load_SymmetricObjectProperty(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomTransitiveObjectProperty)) return load_TransitiveObjectProperty(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomHasKey)) return load_HasKey(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSubAnnotationPropertyOf)) return load_SubAnnotationPropertyOf(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomAnnotationPropertyDomain)) return load_AnnotationPropertyDomain(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomAnnotationPropertyRange)) return load_AnnotationPropertyRange(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomAnnotationAssertion)) return load_AnnotationAssertion(loader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocActions.axiomFunctionDefinition)) return load_FunctionDefinition(loader, node, context);
        throw new FParserException(loader.getInput(), node.getLine(), "Expected an axiom, found " + node.getName());
    }

    private static void load_Base(xowl.lang.owl2.Axiom axiom, Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context)  throws FParserException {
        axiom.setFile(loader.getInput());
        axiom.setLine(node.getLine());
        AnnotationLoader.loadAnnotations(axiom, loader, node, context);
    }

    private static xowl.lang.owl2.Axiom load_Declaration(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.Declaration axiom = new xowl.lang.owl2.Declaration();
        load_Base(axiom, loader, node, context);
        FElementNode child = (FElementNode)node.getChildren().get(0);
        xowl.lang.owl2.IRI iri = (xowl.lang.owl2.IRI)ExpressionLoader.loadEntityExp(loader, child.getChildren().get(0), context);
        axiom.setEntity(iri);
        axiom.setType(child.getName());
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_DisjointClasses(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DisjointClasses axiom = new xowl.lang.owl2.DisjointClasses();
        load_Base(axiom, loader, node, context);
        if (node.getChildren().isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(0))) {
            axiom.setClassSeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(0), context));
        } else {
            List<xowl.lang.owl2.ClassExpression> exps = new ArrayList<xowl.lang.owl2.ClassExpression>();
            for (FNode child : node.getChildren()) {
                xowl.lang.owl2.ClassExpression temp = ExpressionLoader.loadClassExp(loader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setClassSeq(xowl.interpreter.impl.Sequences.toSequence_Class(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DisjointUnion(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DisjointUnion axiom = new xowl.lang.owl2.DisjointUnion();
        load_Base(axiom, loader, node, context);
        axiom.setClasse(ExpressionLoader.loadClassExp(loader, node.getChildren().get(0), context));
        if (node.getChildren().size() == 1)
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(1))) {
            axiom.setClassSeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(1), context));
        } else {
            List<xowl.lang.owl2.ClassExpression> exps = new ArrayList<xowl.lang.owl2.ClassExpression>();
            for (int i=1; i!=node.getChildren().size(); i++) {
                xowl.lang.owl2.ClassExpression temp = ExpressionLoader.loadClassExp(loader, node.getChildren().get(i), context);
                if (temp != null) exps.add(temp);
            }
            axiom.setClassSeq(xowl.interpreter.impl.Sequences.toSequence_Class(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_EquivalentClasses(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.EquivalentClasses axiom = new xowl.lang.owl2.EquivalentClasses();
        load_Base(axiom, loader, node, context);
        if (node.getChildren().isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(0))) {
            axiom.setClassSeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(0), context));
        } else {
            List<xowl.lang.owl2.ClassExpression> exps = new ArrayList<xowl.lang.owl2.ClassExpression>();
            for (FNode child : node.getChildren()) {
                xowl.lang.owl2.ClassExpression temp = ExpressionLoader.loadClassExp(loader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setClassSeq(xowl.interpreter.impl.Sequences.toSequence_Class(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SubClassOf(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.SubClassOf axiom = new xowl.lang.owl2.SubClassOf();
        load_Base(axiom, loader, node, context);
        axiom.setClasse(ExpressionLoader.loadClassExp(loader, node.getChildren().get(0), context));
        axiom.setSuperClass(ExpressionLoader.loadClassExp(loader, node.getChildren().get(1), context));
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_DataPropertyDomain(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DataPropertyDomain axiom = new xowl.lang.owl2.DataPropertyDomain();
        load_Base(axiom, loader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(loader, node.getChildren().get(0), context));
        axiom.setClasse(ExpressionLoader.loadClassExp(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DataPropertyRange(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DataPropertyRange axiom = new xowl.lang.owl2.DataPropertyRange();
        load_Base(axiom, loader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(loader, node.getChildren().get(0), context));
        axiom.setDatarange(ExpressionLoader.loadDatarangeExp(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DisjointDataProperties(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DisjointDataProperties axiom = new xowl.lang.owl2.DisjointDataProperties();
        load_Base(axiom, loader, node, context);
        if (node.getChildren().isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(0))) {
            axiom.setDataPropertySeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(0), context));
        } else {
            List<xowl.lang.owl2.DataPropertyExpression> exps = new ArrayList<xowl.lang.owl2.DataPropertyExpression>();
            for (FNode child : node.getChildren()) {
                xowl.lang.owl2.DataPropertyExpression temp = ExpressionLoader.loadDataPropExp(loader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setDataPropertySeq(xowl.interpreter.impl.Sequences.toSequence_DataProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_EquivalentDataProperties(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.EquivalentDataProperties axiom = new xowl.lang.owl2.EquivalentDataProperties();
        load_Base(axiom, loader, node, context);
        if (node.getChildren().isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(0))) {
            axiom.setDataPropertySeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(0), context));
        } else {
            List<xowl.lang.owl2.DataPropertyExpression> exps = new ArrayList<xowl.lang.owl2.DataPropertyExpression>();
            for (FNode child : node.getChildren()) {
                xowl.lang.owl2.DataPropertyExpression temp = ExpressionLoader.loadDataPropExp(loader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setDataPropertySeq(xowl.interpreter.impl.Sequences.toSequence_DataProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_FunctionalDataProperty(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.FunctionalDataProperty axiom = new xowl.lang.owl2.FunctionalDataProperty();
        load_Base(axiom, loader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(loader, node.getChildren().get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SubDataPropertyOf(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.SubDataPropertyOf axiom = new xowl.lang.owl2.SubDataPropertyOf();
        load_Base(axiom, loader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(loader, node.getChildren().get(0), context));
        axiom.setSuperDataProperty(ExpressionLoader.loadDataPropExp(loader, node.getChildren().get(1), context));
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_DatatypeDefinition(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DatatypeDefinition axiom = new xowl.lang.owl2.DatatypeDefinition();
        load_Base(axiom, loader, node, context);
        axiom.setDatatype(ExpressionLoader.loadDatarangeExp(loader, node.getChildren().get(0), context));
        axiom.setDatarange(ExpressionLoader.loadDatarangeExp(loader, node.getChildren().get(1), context));
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_ClassAssertion(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.ClassAssertion axiom = new xowl.lang.owl2.ClassAssertion();
        load_Base(axiom, loader, node, context);
        axiom.setClasse(ExpressionLoader.loadClassExp(loader, node.getChildren().get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DataPropertyAssertion(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DataPropertyAssertion axiom = new xowl.lang.owl2.DataPropertyAssertion();
        load_Base(axiom, loader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(loader, node.getChildren().get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(loader, node.getChildren().get(1), context));
        axiom.setValueLiteral(ExpressionLoader.loadLiteralExp(loader, node.getChildren().get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DifferentIndividuals(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DifferentIndividuals axiom = new xowl.lang.owl2.DifferentIndividuals();
        load_Base(axiom, loader, node, context);
        if (node.getChildren().isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(0))) {
            axiom.setIndividualSeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(0), context));
        } else {
            List<xowl.lang.owl2.IndividualExpression> exps = new ArrayList<xowl.lang.owl2.IndividualExpression>();
            for (FNode child : node.getChildren()) {
                xowl.lang.owl2.IndividualExpression temp = ExpressionLoader.loadIndividualExp(loader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setIndividualSeq(xowl.interpreter.impl.Sequences.toSequence_Ind(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_NegativeDataPropertyAssertion(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.NegativeDataPropertyAssertion axiom = new xowl.lang.owl2.NegativeDataPropertyAssertion();
        load_Base(axiom, loader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(loader, node.getChildren().get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(loader, node.getChildren().get(1), context));
        axiom.setValueLiteral(ExpressionLoader.loadLiteralExp(loader, node.getChildren().get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_NegativeObjectPropertyAssertion(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.NegativeObjectPropertyAssertion axiom = new xowl.lang.owl2.NegativeObjectPropertyAssertion();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(loader, node.getChildren().get(1), context));
        axiom.setValueIndividual(ExpressionLoader.loadIndividualExp(loader, node.getChildren().get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_ObjectPropertyAssertion(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.ObjectPropertyAssertion axiom = new xowl.lang.owl2.ObjectPropertyAssertion();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(loader, node.getChildren().get(1), context));
        axiom.setValueIndividual(ExpressionLoader.loadIndividualExp(loader, node.getChildren().get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SameIndividual(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.SameIndividual axiom = new xowl.lang.owl2.SameIndividual();
        load_Base(axiom, loader, node, context);
        if (node.getChildren().isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(0))) {
            axiom.setIndividualSeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(0), context));
        } else {
            List<xowl.lang.owl2.IndividualExpression> exps = new ArrayList<xowl.lang.owl2.IndividualExpression>();
            for (FNode child : node.getChildren()) {
                xowl.lang.owl2.IndividualExpression temp = ExpressionLoader.loadIndividualExp(loader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setIndividualSeq(xowl.interpreter.impl.Sequences.toSequence_Ind(exps));
        }
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_AsymmetricObjectProperty(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.AsymmetricObjectProperty axiom = new xowl.lang.owl2.AsymmetricObjectProperty();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DisjointObjectProperties(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.DisjointObjectProperties axiom = new xowl.lang.owl2.DisjointObjectProperties();
        load_Base(axiom, loader, node, context);
        if (node.getChildren().isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(0))) {
            axiom.setObjectPropertySeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(0), context));
        } else {
            List<xowl.lang.owl2.ObjectPropertyExpression> exps = new ArrayList<xowl.lang.owl2.ObjectPropertyExpression>();
            for (FNode child : node.getChildren()) {
                xowl.lang.owl2.ObjectPropertyExpression temp = ExpressionLoader.loadObjPropExp(loader, child, context);
                if(temp != null) exps.add(temp);
            }
            axiom.setObjectPropertySeq(xowl.interpreter.impl.Sequences.toSequence_ObjProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_EquivalentObjectProperties(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.EquivalentObjectProperties axiom = new xowl.lang.owl2.EquivalentObjectProperties();
        load_Base(axiom, loader, node, context);
        if (node.getChildren().isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(node.getChildren().get(0))) {
            axiom.setObjectPropertySeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)node.getChildren().get(0), context));
        } else {
            List<xowl.lang.owl2.ObjectPropertyExpression> exps = new ArrayList<xowl.lang.owl2.ObjectPropertyExpression>();
            for (FNode child : node.getChildren()) {
                xowl.lang.owl2.ObjectPropertyExpression temp = ExpressionLoader.loadObjPropExp(loader, child, context);
                if(temp != null) exps.add(temp);
            }
            axiom.setObjectPropertySeq(xowl.interpreter.impl.Sequences.toSequence_ObjProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_FunctionalObjectProperty(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.FunctionalObjectProperty axiom = new xowl.lang.owl2.FunctionalObjectProperty();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_InverseFunctionalObjectProperty(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.InverseFunctionalObjectProperty axiom = new xowl.lang.owl2.InverseFunctionalObjectProperty();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_InverseObjectProperties(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.InverseObjectProperties axiom = new xowl.lang.owl2.InverseObjectProperties();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        axiom.setInverse(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_IrreflexiveObjectProperty(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.IrreflexiveObjectProperty axiom = new xowl.lang.owl2.IrreflexiveObjectProperty();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_ObjectPropertyDomain(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.ObjectPropertyDomain axiom = new xowl.lang.owl2.ObjectPropertyDomain();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        axiom.setClasse(ExpressionLoader.loadClassExp(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_ObjectPropertyRange(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.ObjectPropertyRange axiom = new xowl.lang.owl2.ObjectPropertyRange();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        axiom.setClasse(ExpressionLoader.loadClassExp(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_ReflexiveObjectProperty(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.ReflexiveObjectProperty axiom = new xowl.lang.owl2.ReflexiveObjectProperty();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SubObjectPropertyOf(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.SubObjectPropertyOf axiom = new xowl.lang.owl2.SubObjectPropertyOf();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        axiom.setSuperObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SymmetricObjectProperty(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.SymmetricObjectProperty axiom = new xowl.lang.owl2.SymmetricObjectProperty();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_TransitiveObjectProperty(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.TransitiveObjectProperty axiom = new xowl.lang.owl2.TransitiveObjectProperty();
        load_Base(axiom, loader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(loader, node.getChildren().get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_HasKey(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.HasKey axiom = new xowl.lang.owl2.HasKey();
        load_Base(axiom, loader, node, context);
        axiom.setClasse(ExpressionLoader.loadClassExp(loader, node.getChildren().get(0), context));
        FElementNode ObjProps = (FElementNode)node.getChildren().get(1);
        if (!ObjProps.getChildren().isEmpty()) {
            if (ExpressionLoader.isToSeqNode(ObjProps.getChildren().get(0))) {
                axiom.setObjectPropertySeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)ObjProps.getChildren().get(0), context));
            } else {
                List<xowl.lang.owl2.ObjectPropertyExpression> exps = new ArrayList<xowl.lang.owl2.ObjectPropertyExpression>();
                for (FNode child : ObjProps.getChildren()) {
                    xowl.lang.owl2.ObjectPropertyExpression temp = ExpressionLoader.loadObjPropExp(loader, child, context);
                    if(temp != null) exps.add(temp);
                }
                axiom.setObjectPropertySeq(xowl.interpreter.impl.Sequences.toSequence_ObjProp(exps));
            }
        }
        FElementNode DataProps = (FElementNode)node.getChildren().get(1);
        if (!DataProps.getChildren().isEmpty()) {
            if (ExpressionLoader.isToSeqNode(DataProps.getChildren().get(0))) {
                axiom.setDataPropertySeq(ExpressionLoader.load_ToSeq(loader, (FElementNode)DataProps.getChildren().get(0), context));
            } else {
                List<xowl.lang.owl2.DataPropertyExpression> exps = new ArrayList<xowl.lang.owl2.DataPropertyExpression>();
                for (FNode child : DataProps.getChildren()) {
                    xowl.lang.owl2.DataPropertyExpression temp = ExpressionLoader.loadDataPropExp(loader, child, context);
                    if (temp != null) exps.add(temp);
                }
                axiom.setDataPropertySeq(xowl.interpreter.impl.Sequences.toSequence_DataProp(exps));
            }
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SubAnnotationPropertyOf(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.SubAnnotationPropertyOf axiom = new xowl.lang.owl2.SubAnnotationPropertyOf();
        load_Base(axiom, loader, node, context);
        axiom.setAnnotProperty(AnnotationLoader.loadAnnotationProperty(loader, node.getChildren().get(0), context));
        axiom.setSuperAnnotProperty(AnnotationLoader.loadAnnotationProperty(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_AnnotationPropertyDomain(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.AnnotationPropertyDomain axiom = new xowl.lang.owl2.AnnotationPropertyDomain();
        load_Base(axiom, loader, node, context);
        axiom.setAnnotProperty(AnnotationLoader.loadAnnotationProperty(loader, node.getChildren().get(0), context));
        axiom.setAnnotDomain(AnnotationLoader.loadAnnotationIRI(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_AnnotationPropertyRange(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.AnnotationPropertyRange axiom = new xowl.lang.owl2.AnnotationPropertyRange();
        load_Base(axiom, loader, node, context);
        axiom.setAnnotProperty(AnnotationLoader.loadAnnotationProperty(loader, node.getChildren().get(0), context));
        axiom.setAnnotRange(AnnotationLoader.loadAnnotationIRI(loader, node.getChildren().get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_AnnotationAssertion(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.owl2.AnnotationAssertion axiom = new xowl.lang.owl2.AnnotationAssertion();
        load_Base(axiom, loader, node, context);
        axiom.setAnnotProperty(AnnotationLoader.loadAnnotationProperty(loader, node.getChildren().get(0), context));
        axiom.setAnnotSubject(AnnotationLoader.loadAnnotationSubject(loader, node.getChildren().get(1), context));
        axiom.setAnnotValue(AnnotationLoader.loadAnnotationValue(loader, node.getChildren().get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_FunctionDefinition(Loader loader, FElementNode node, xowl.interpreter.frontends.LexicalContext context) throws FParserException {
        xowl.lang.actions.FunctionDefinition axiom = new xowl.lang.actions.FunctionDefinition();
        load_Base(axiom, loader, node, context);
        axiom.setFunction(ExpressionLoader.loadFunctionExp(loader, node.getChildren().get(0), context));
        axiom.setBehavior(ExpressionLoader.loadExecutableExp(loader, node.getChildren().get(1), context));
        return axiom;
    }
}
